<?php
	require "modifyPage.php";
	$program = $_REQUEST["program"];
	$stm = $tmpConnection->prepare('insert into content (titel,background,special,creator,created) values (:titel, 1, 0, :creator, :created)');
	$now = date("Y-m-d H:i:s");
	$stm->execute(array(':titel' => 'Pagina ' . $now, ':creator' => $app->theUser, ':created' => $now));
	$stm = $tmpConnection->prepare('select id from content where id = (select max(id) from content)');
	$stm->execute();
	$rs = $stm->fetch(PDO::FETCH_ASSOC);
	$position = $rs['id'];

	$stm = $tmpConnection->prepare('select volgorde from programs where id=:id');
	$stm->execute(array(':id' => $program));
	$rs = $stm->fetch(PDO::FETCH_ASSOC);
	var_dump($rs);
	$volgorde = explode(";", $rs['volgorde']);

	$volgorde[] = $position;
	$newVolgorde = implode(";", $volgorde);
	var_dump($volgorde);
	var_dump($newVolgorde);
	$stm = $tmpConnection->prepare("update programs set volgorde=:volgorde where id=:id");
	$stm->execute(array(':volgorde' => $newVolgorde, ':id' => $program));

	editPage($program, $position);

?>